package 二叉树;

import common.TreeNode;

/**
 * @author tmh
 * @date 2024/8/21 20:44
 * @description
 */
public class T104二叉树的最大深度 {
    public int maxDepth(TreeNode root) {
        if (root == null) {
            return 0;
        }
        int leftDepth = maxDepth(root.left);
        int rightDepth = maxDepth(root.right);
        return Math.max(leftDepth, rightDepth) + 1;
    }
}
